--TEST--
Objects and __toString()
--FILE--
<?php
/**
 * Test file to test objects that have __toString() magic method
 * (PHP 5.2.0+ required for this test)
 *
 * PHP version 5
 *
 * @category  Stream
 * @package   Stream_Iterate
 * @author    Philippe Jausions <Philippe.Jausions@11abacus.com>
 * @copyright 2008 by 11abacus / Philippe Jausions
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @link      http://pear.11abacus.com/package/Stream_Iterate
 */

/**
 * Required package to test
 */
require_once 'Stream/Iterate.php';

/**
 * Basic class of objects
 */
class A
{
    /**
     * Holds instance's data
     *
     * @var mixed
     */
    private $_v;

    /**
     * Class constructor
     *
     * @param mixed $value some data
     */
    public function __construct($value)
    {
        $this->_v = $value;
    }

    /**
     * Turns object into a string
     *
     * @return string Output
     */
    public function __toString()
    {
        return serialize($this->_v);
    }
}

/**
 * Main
 */

// Register protocol
stream_wrapper_register('foreach', 'Stream_Iterate');

$data = array('letters' => new A('abc'), 'numbers' => new A(123));

// Create the context for the stream
$context = stream_context_create(array('foreach' => array(
                                                 'subject'  => &$data)));
// Open the stream
$fp = fopen('foreach://value@subject', 'r', false, $context);

set_time_limit(1);
if (!$fp) {
    echo 'Could not open path';
    return;
}
while (!feof($fp)) {
    echo fgets($fp);
}
fclose($fp);

?>
--EXPECT--
s:3:"abc";i:123;
